/**
 * Copyright (c) 2009-2011, chunquedong(YangJiandong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 
 * History:
 *     2010-05-05  Jed Young  Creation
 */
package chunmap.raster.gmap;

import java.awt.Image;

import chunmap.model.elem.Envelope;
import chunmap.raster.Tile;

public class GMTile extends Tile{
	private GMDataSource datasource;

    public GMTile(int x, int y, int z)
    {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public void setDataSource(GMDataSource datasource)
    {
        this.datasource = datasource;
        if(proxy!=null){
        	proxy.datasource=datasource;
        }
    }

    public @Override Envelope getEnvelop()
    {
        return datasource.getEnvelope(this);
    }

    public @Override Image getImage()
    {
        return datasource.getImage(this);
    }
    
    @Override
    public void setEnvelop(Envelope envelope){
    	super.setEnvelop(envelope);
    	if(proxy!=null){
    		proxy.setEnvelop(envelope);
    	}
    }

    //------------------------------------------------------------------------

    public GMTile proxy;

    public void createProxy()
    {
        if (proxy == null)
        {
            proxy = new GMTile(x,y,z);
        }
    }
}